home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0493 / TV-F1112.TXT < prev    next >
Text File  |  1993-04-22  |  6KB  |  145 lines

  1. ─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 363 of 534                                                               
  3. From : Michael Nicolai                     2:2401/411.2         20 Apr 93  01:00 
  4. To   : Christopher Turcksin                2:292/608.3                           
  5. Subj : TurboVision F11/F12                                                    
  6. ────────────────────────────────────────────────────────────────────────────────
  7. > Hello there!
  8. > I noticed TurboVision doesn't support the F11 and F12 keys, since it uses 
  9. > the standard DOS/BIOS calls to read the keyboard which doesn't support those 
  10.  
  11. Wrong! See INT 16h.
  12.  
  13. > keys either. However, Borland made it quite easy to implement this 'feature' 
  14. > in our TV apps. The only thing needed to do is override the 
  15. > TProgram.GetKeyEvent method in the app's TMyApplication (or whatever you 
  16. > derived from TApplication) object.
  17. > However, I'm in trouble here since I don't have enough information on the 
  18. > extended keyboard services. So, if someone here would be so kind to supply 
  19. > me with the necessary information, I owe him a beer or two.
  20. > Using the extended keyboard services has one disadvantage, but there's a 
  21. > workaround. It won't run on XT-type machines or AT's with an XT keyboard 
  22. > (are they still around?). The program can detect the presence of an extended 
  23. > keyboard, so if it's not available, it should call the original GetKeyEvent 
  24. > instead. Also, the commands mapped to the F11/F12 keys should also be 
  25. > available using an ALT-F1..10 combination (like in WP, ALT-F4 = F12) ...
  26. > One additional advantage of using the extended keyboard is that you can 
  27. > detect if the key was pressed on the numerical keyboard. Although I think 
  28. > this is possible now too (the scancode is different for the + and the gray +)
  29. > Christopher, TLA Crew Member
  30.  
  31. Since you only program on ATs, use this little function:
  32.  
  33. uses DOS;
  34.  
  35. function Get_Extended_KeyCode : word;
  36. var
  37.  regs : Registers;
  38. begin
  39.  regs.ah := $10;
  40.  intr($16, regs);
  41.  Get_Extended_KeyCode := (regs.ah shl 4) + regs.al;
  42. end;
  43.  
  44. This function waits until a key is pressed.
  45. The upper byte contains the scan code, the lower byte contains the ASCII
  46. code.
  47. If you don't want your program to hang if no key is pressed, use this
  48. funtion to check if any keycode is actually present in the keyboard buffer:
  49.  
  50. uses DOS;
  51.  
  52. function Check_For_Extended_KeyStroke : boolean;  { like KEYPRESSED }
  53. var
  54.  regs : Registers;
  55. begin
  56.  regs.ah := $11;
  57.  intr($16, regs);
  58.  Check_For_Extended_Keystroke := FALSE;
  59.  if ((regs.flags and fzero) = 0) then
  60.   Check_For_Extended_Keystroke := TRUE;
  61. end;
  62.  
  63. After this function returns TRUE, the keycode can be read with
  64. 'Get_Extended_KeyCode'.
  65.  
  66.  
  67. Here are the routines my functions are based on:
  68.  
  69. INTERRUPT 16h - Function 10h
  70. Keyboard - Get enhanced keystroke
  71.  
  72. Purpose: Wait for any keyboard input.
  73. Available on: AT or PS/2 with enhanced keyboard support only.
  74. Restrictions: none.
  75. Registers at call: AH = 10h.
  76. Return Registers: AH = scan code, AL = ASCII code
  77. Details: If no keystroke is available, this function waits until one is
  78.          placed in the keyboard buffer. Unlike function 00h, this function
  79.          does not discard extended keystrokes.
  80. Conflicts: none known.
  81.  
  82.  
  83. INTERRUPT 16h - Function 11h
  84. Keyboard - Check for enhanced keystroke
  85.  
  86. Purpose: Checks for availability of any keyboard input.
  87. Available on: AT or PS/2 with enhanced keyboard only.
  88. Restrictions: none.
  89. Registers at call: AH = 11h
  90. Return Registers: ZF set if no keystroke available
  91.                   ZF clear if keystroke available
  92.                      AH = scan code
  93.                      AL = ASCII code
  94. Details: If a keystroke is available, it is not removed from the keyboard
  95.          buffer. Unlike function 01h, this function does not discard extended
  96.          keystrokes.
  97. conflicts: none known.
  98.  
  99.  
  100. INTERRUPT 16h - Function 12h
  101. Keyboard - Get extended shift states
  102.  
  103. Purpose: Returns all shift-flags information from enhanced keyboards.
  104. Available: AT or PS/2 with enhanced keyboard only.
  105. Restrictions: none.
  106. Registers at call: AH = 12h
  107. Return Registers: AL = shift flags 1 (same as returned by function 02h):
  108.                        bit 7: Insert active
  109.                            6: CapsLock active
  110.                            5: NumLock active
  111.                            4: ScrollLock active
  112.                            3: Alt key pressed (either Alt on 101/102-key
  113.                               keyboard)
  114.                            2: Crtl key pressed (either Ctrl on 101/102-key
  115.                               keyboard)
  116.                            1: left shift key pressed
  117.                            0: right shift key pressed
  118.  
  119.                   AH = shift flags 2:
  120.                        bit 7: SysRq key pressed
  121.                            6: CapsLock pressed
  122.                            5: NumLock pressed
  123.                            4: ScrollLock pressed
  124.                            3: right Alt key prssed
  125.                            2: right Ctrl key pressed
  126.                            1: left Alt key pressed
  127.                            0: left Ctrl key pressed
  128. Details: AL bit 3 is set only for left Alt key on many machines. AH bits 7
  129.          through 4 are always clear on a Compaq SLT/286.
  130. Conflicts: none known.
  131.  
  132.  
  133. So, i hope this will help you.
  134.  
  135. Oh, and since i drink no beer, a coke would be nice. :-)
  136.  
  137.  
  138. Michael : [NICO] : [Whoo haz broquen mei brain-waschaer?]
  139. ~~~~~~~~~~~~~~~~
  140.